<include file="public:header" />
<!--编辑管理员-->
<div class="pad_lr_10">
	<div class="col_tab">
		<ul class="J_tabs tab_but cu_li">
			<li class="current">编辑账号</li>			
		</ul>
     <div class="content_list pad_10">   
	<form id="info_form" name="info_form" action="{:u('admin/edit')}" method="post">
    <input type="hidden" name="id" value="{$info.id}" />
	<table width="100%" class="table_form">
		<tr> 
	      <th width="80">{:L('admin_userName')} :</th>
	      <td><input type="text" name="userName" id="J_userName" value="{$info.userName}" class="input-text"></td>
	    </tr>
	    <tr> 
	      <th>{:L('passWord')} :</th>
	      <td><input type="text" name="passWord" id="J_password" value="" class="input-text"></td>
	    </tr>
	    <tr>
	    	<th>{:L('user_phone')} :</th>
	    	<td><input type="text" name="phone" class="input-text" value="{$info.phone}" size="30"></td>
	    </tr>        
	    <tr>
	    	<th>{:L('admin_email')} :</th>
	    	<td><input type="text" name="email" class="input-text" value="{$info.email}" size="30"></td>
	    </tr>  

        <if condition="$_SESSION['admin']['roleId']  eq 1">
	    <tr>
	    	<th>{:L('real_name')} :</th>
	    	<td><input type="text" name="realName" class="input-text" value="{$info.realName}"  size="30"></td>
	    </tr>
      
        
	    <tr>
	    	<th>{:L('user_company')} :</th>
	    	<td><input type="text" name="company" class="input-text" value="{$info.company}" size="30"></td>
	    </tr>        
 	    <tr>
	    	<th>{:L('user_job_post')} :</th>
	    	<td><input type="text" name="jobPost" class="input-text" value="{$info.jobPost}" size="30"></td>
	    </tr>        
       

	    <tr>
	      <th>{:L('admininrole')} :</th>
	      <td>
	      	<select name="roleId" id="roleId">
                <option value="">{:L('please_select')}</option>
	        	<volist name="role_list" id="val">
	        	  <option value="{$val.id}" level_id="{$val.regionLevel}" select_customer="{$val.selectCustomer}" 
                    <if condition="$info['roleId'] eq $val['id']">selected="true"</if>>
                    {$val.name}</option>
	            </volist>
	        </select>
            
	      </td>
	    </tr>
 	    <tr>
	      <th>{:L('select_region')} :</th>
	      <td>
                    <select class="J_cate_select mr10" data-pid="0" data-uri="{:U('region/ajax_getchilds')}" data-selected=""></select>
                    <input type="hidden" name="regionId" id="J_cate_id" value="{$search.cate_id}" />            
	      </td>
	    </tr>
       
       <tr>
            <th>入职时间:</th>
            <td><input type="text" name="entryTime" value="{$info.entryTime}" /></td>
       </tr>  
       
       <tr>
            <th>离职时间:</th>
            <td><input type="text" name="leavingTime" value="{$info.leavingTime}" /></td>
       </tr>
       
       <tr>
            <td colspan=2>
            <table>
                <tr>
                    <th>培训时间：</th>
                    <td><input type="text" name="trainTime" value="{$userTrain.trainTime}" /></td>
                    <th>培训内容：</th>
                    <td colspan=2><input type="text" name="trainCon" value="{$userTrain.trainCon}" /></td>
                </tr>
                <tr>
                    <th>原职位：</th>
                    <td><input type="text" name="oldPosition" value="{$userHistory.oldPosition}" /></td>
                    <th>调职时间：</th>
                    <td><input type="text" name="transferTime" value="{$userHistory.transferTime}" /></td>                    
                </tr>                
            </table>
            </td>
       </tr> 
       </if>            
	</table>

    </div>
    </div>
    <div class="mt10"><input type="submit" value="{:L('submit')}" id="dosubmit" name="dosubmit" class="btn btn_submit" style="margin:0 0 10px 100px;"><br /><br /><br /></div>
</div>
	</form>
<include file="public:footer" />
<script>
$(function(){
	$.formValidator.initConfig({formid:"info_form",autotip:true});
	var check_name_url = "{:U('admin/ajax_check_name', array('id'=>$info['id']))}";	
	$("#J_userName").formValidator({ onshow:lang.please_input+lang.admin_username, onfocus:lang.please_input+lang.admin_username}).inputValidator({ min:1, onerror:lang.please_input+lang.admin_username}).ajaxValidator({type:"get", url:check_name_url, data:"", datatype:"html", async:'false', success:function(data){ if(data == "1"){return true;}else{return false;}}, onerror:lang.admin_name_exists, onwait:lang.connecting_please_wait});
    
	//$("#J_password").formValidator({ onshow:lang.please_input+lang.password+lang.default_password, onfocus:lang.password+lang.between_6_to_20}).inputValidator({min:0, max:20, onerror:lang.password+lang.between_6_to_20, oncorrect:"d"});
    



});    
    
    $("#roleId").change(function(){       
        var _this = $(this);
        var role_id = _this.val();        
        var option=$("option:selected",_this);
        var level_id = option.attr("level_id");
        var select_customer = option.attr("select_customer");
        level_id = Number(level_id);
        $(".J_cate_select:first").attr('data-selected',"");
        if(role_id){
            var data_uri = "/index.php?g=admin&m=region&a=ajax_getchilds&max_level="+level_id;
            if(level_id>2){
                data_uri +="&type=store";
            }
            $(".J_cate_select").attr("data-uri",data_uri);
            $('.J_cate_select').empty();
            $('.J_cate_select').cate_select();
            
            // 需要选择客户
            if(select_customer==1){
                $("#customerIds").show();
            }else{
                $("input[name='customerIds[]']").each(function(){
                   $(this).attr("checked",false);
                });              
                $("#customerIds").hide();
            }
        }       
    });


    //imei 和 sim 层的显示与隐藏
    var speed = 1500;
    $("#iframe_sim").hide();
    $("#iframe_imei").hide();
    $("#select_sim").click(function(){
       $("#iframe_sim").show(speed); 
    });    
    $("#imei_con").focus(function(){
        $("#iframe_imei").show(speed); 
    });   
    $("#sim_con").focus(function(){
        $("#iframe_sim").show(speed); 
    });    
    $("#select_imei").click(function(){
       $("#iframe_imei").show(speed); 
    });   
    $("#sim_con").focusout(function(){     
        $("#iframe_sim").hide(speed);
    });
    $("#imei_con").focusout(function(){     
        $("#iframe_imei").hide(speed);
    });    
    function select_imei_click(v){
         $("#imei_con").val(v);
         $("#iframe_imei").hide(speed);
    }
    function select_sim_click(v){
         $("#sim_con").val(v);
         $("#iframe_sim").hide(speed);
    }
    
     //取地区路径
    var storeId = "{$info['storeId']}";
    var ajax_get_spid = "{:U('region/ajax_get_spid', array('id'=>$info['regionId']))}";
    var regionId = "{$info['regionId']}";
    
    $.ajax({url:ajax_get_spid,success:function(con){
       if(storeId!=""){
            con +=regionId+"_"+storeId+"|";
       }
       $('.J_cate_select').attr('data-selected',con+"");
            var level_id = "{$role_list[$info['roleId']]['regionLevel']}";
            var data_uri = "/index.php?g=admin&m=region&a=ajax_getchilds&max_level="+level_id;
            
            if(level_id>2){
                data_uri +="&type=store";
            }
            $(".J_cate_select").attr("data-uri",data_uri);       
       
       //联动查询
    	$('.J_cate_select').cate_select();    
        //$("#roleId").change();    
    }});
        
    
</script>

</body>
</html>